package com.eslserver.to.wrapper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.eslserver.dao.DAOException;
import com.eslserver.to.Schedule;
import com.eslserver.util.FormatUtil;

public class ScheduleWrapper {
	public static final Logger LOG = LoggerFactory
			.getLogger(ScheduleWrapper.class);

	private Schedule schedule;
	private String startDate;
	private String startTime;
	private String repeat;
	private static final String REPEAT = "yes";
	private static final String SINGLE = "no";

	private ScheduleWrapper(Schedule schedule) {
		this.schedule = schedule;
		this.startDate = FormatUtil.getUSDate(schedule.getStartTime());
		this.startTime = FormatUtil.getTime(schedule.getStartTime());

		setRepeat(schedule.isRepeat());
	}

	public static ScheduleWrapper createScheduleWrapper(Schedule eslPushSchedule) {
		return new ScheduleWrapper(eslPushSchedule);
	}

	public Schedule getSchedule() {
		return schedule;
	}

	public void setSchedule(Schedule schedule) {
		this.schedule = schedule;
	}

	public Integer getScheduleID() {
		return schedule.getScheduleID();
	}

	public String getName() {
		return schedule.getName();
	}

	public String getDescription() {
		return schedule.getDescription();
	}

	public String getStartDate() {
		return startDate;
	}

	public String getStartTime() {
		return startTime;
	}

	public void setRepeat(boolean isRepeat) {
		if (isRepeat) {
			repeat = REPEAT;
		} else {
			repeat = SINGLE;
		}
	}

	public String getRepeat() {
		return repeat;
	}

	public Integer getTimeInterval() {
		return schedule.getTimeInterval();
	}

	public String getImageName() throws DAOException {
		return ImageWrapper.createESLImageWrapper(schedule.getImage())
				.getName();
	}
}
